package thread;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class ThreadTest {
	static boolean flag = false;
	String msg1="A";
	String msg2="B";
	
	@Test
	public void test() {
		List<Integer> list = new ArrayList<>();
		for(int i=0 ;i<1000;i++) {
			list.add(i);
		}
		list.stream().forEach(item ->{
			ThreadTest tt1 = new ThreadTest();
			ThreadTest tt2 = new ThreadTest();
			Thread t1 = new Thread(tt1.new MyThread(msg1));
			Thread t2 = new Thread(tt2.new MyThread(msg2));
			t1.start();
			t2.start();
		});
		
	}
	
	
	public String getMsg1() {
		return msg1;
	}
	public String getMsg2() {
		return msg2;
	}

	class MyThread implements Runnable{
		String text;
		MyThread(String text){
			this.text = text;
		}
		
		@Override
		public void run() {
			text += text;
			System.out.println(text);
		}
	}
}
